From bbeb6c97421bc56a35d38ef99ccf6a1ea4ef4fad Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 11 Aug 2003 16:30:55 +0000 Subject: [PATCH] Use isatty instead of stat/S_ISCHR to determine "serialness". --- magproto.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/magproto.c b/magproto.c index 888c47ff0..9e68eb590 100644 --- a/magproto.c +++ b/magproto.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "defs.h" #include "magellan.h" @@ -631,7 +630,6 @@ static void terminit(const char *portname) { struct termios new_tio; - struct stat sbuf; magfile_in = fopen(portname, "rb"); @@ -640,8 +638,7 @@ terminit(const char *portname) portname, strerror(errno)); } - fstat(fileno(magfile_in), &sbuf); - is_file = S_ISREG(sbuf.st_mode); + is_file = !isatty(fileno(magfile_in)); if (is_file) { icon_mapping = map330_icon_table; mag_cleanse = m330_cleanse; @@ -757,14 +754,12 @@ mag_wr_init(const char *portname, const char *args) is_file = 1; } #else - struct stat sbuf; magfile_out = fopen(portname, "w+b"); if (!magfile_out) { fatal(MYNAME ": '%s' cannot be opened for writing.\n", portname); } - fstat(fileno(magfile_out), &sbuf); - is_file = S_ISREG(sbuf.st_mode); + is_file = !isatty(fileno(magfile_out)); #endif if (!mkshort_handle) { -- 2.30.2